#!/bin/bash

set -e

function usage() {
    echo -n \
"Usage: $(basename "$0")

Publish container images built from templates.
"
}

if [ "${BASH_SOURCE[0]}" = "${0}" ]; then
    if [ "${1:-}" = "--help" ]; then
        usage
    else
        # Strip the patch number off of GDAL_VERSION for tagging
        GDAL_MAJOR_VERSION=$(echo "${GDAL_VERSION}" | cut -d "." -f 1,2)

        docker login -u "${QUAY_USER}" -p "${QUAY_PASSWORD}" quay.io

        docker push "quay.io/azavea/openjdk-gdal:$GDAL_MAJOR_VERSION-jdk$OPENJDK_VERSION-$VARIANT"
    fi
fi
